package com.example.common.vo;

import com.example.common.exception.YebException;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class RespBean {

    private Integer code;

    private String message;

    private Object obj;


    public static final RespBean AUTH_FAILED_ERROR_401 = new RespBean(401,"用户登录过期，需重新登录！",null);

    public static final RespBean SIGN_VERIFY_FAILED_ERROR_202 = new RespBean(202,"签名异常",null);

    public static final RespBean AUTH_FAILED_ERROR_402 = new RespBean(402,"用户名或者密码错误！",null);

    public static final RespBean AUTH_FAILED_ERROR_404 = new RespBean(404,  null,null);

    public static final RespBean AUTH_FAILED_ERROR_411 = new RespBean(411,"用户不具备权限，拒绝访问！",null);

    public static final RespBean AUTH_FAILED_ERROR_500 = new RespBean(500,"更新权限异常！",null);

    public static final RespBean AUTH_FAILED_ERROR_503 = new RespBean(503,"更新用户角色失败！",null);


    public YebException toException(){
        return new YebException(code,message);
    }

    public RuntimeException toRunException(){
        return new RuntimeException();
    }

    public static RespBean success(String msg, Object data) {

        return new RespBean(200, msg, data);
    }

    public static RespBean success(Object data) {

        return success("请求成功", data);
    }

    public static RespBean success() {

        return success(null);
    }

    public static RespBean error(Integer code, String msg) {

        return new RespBean(code, msg, null);
    }



}
